SDA 4.1 Documentation for XCONVERT EXAMPLES


NAME

XCONVERT examples - data definition files handled by XCONVERT

DESCRIPTION

Some examples of the data definition files for SAS and SPSS that will work with XCONVERT are given below. See the main XCONVERT document for a discussion of all the program options.

The following examples are included:



1. SAS data definitions

 /*  SAS Data Definition File                        */

TITLE "SDA Test Data";
FILENAME INDATA "    ";      /* Put name of data file between quotes */
LIBNAME LIBRARY "    ";    /* Put directory of data library between quotes */

PROC  FORMAT LIB=LIBRARY;
  VALUE age       97='97+ yrs' 99='Refused' ;
  VALUE educ      8='thru 8th' 12='HS  grad' 16='Col grad' 99='Refused' ;
  VALUE employed  10='Fulltime' 15='Parttime' 20='Laid off' 40='Unemployed'
                  50='Retired' 60='Perm disabled' 65='Temp disabled'
                  70='Keep house' 80='Student' 90='Other' 99='Refused' ;
  VALUE gender    1='Male' 2='Female' ;
  VALUE income    1='< 15' 2='15' 3='15- 25' 4='25' 5='25- 35' 6='35'
                  7='35- 40' 8='40' 9='40- 50' 10='50' 11='50+' 81='25- 40'
                  82='>25' 83='>40' 84='<25' 88='DK' 91='25- 40' 92='>25'
                  93='>40' 94='<25' 99='Refused' ;
  VALUE marital   1='Married' 2='Like married' 3='Widowed' 4='Separated'
                  5='Divorced' 6='Never married' 8='Don''t know' 9='Refused' ;
  VALUE spend     1='Too much' 3='About right' 5='Too little' 8='Don''t know'
                  9='Refused' ;
  VALUE spend2ff  1='Too much' 3='About right' 5='Too little' 8='Don''t know'
                  9='Refused' ;
  VALUE spend3ff  1='Too much' 3='About right' 5='Too little' 8='Don''t know'
                  9='Refused' ;
  VALUE spend4ff  1='Too much' 3='About right' 5='Too little' 8='Don''t know'
                  9='Refused' ;
  VALUE eqopp     1='Agree' 5='Disagree' 8='Don''t know' 9='Refused' ;
  VALUE eqrandom  1='Blacks' 2='Women' ;
  VALUE ideo      1='Liberal' 3='Conservative' 5='Moderate' 7='Don''t label'
                  8='DK' 9='Refused' ;
  VALUE party     1='Republican' 3='Democrat' 5='Independent'
                  6='No preference' 7='Other' 8='Don''t know' 9='Refused' ;
  VALUE race      1='White' 2='Black' 3='Hispanic' 4='Native American'
                  5='Asian' 6='Filipino' 7='Vol: Jewish' 8='Other'
                  99='Refused' ;
RUN;

DATA IN (LABEL="SDA Test Data");
  INFILE INDATA LRECL=72;
  INPUT
    #1  CASEID 5-10             charid $5-10            age 3-4
        casewt 11-16 .3         educ 19-20              employed 23-24
        gender 28               income 31-32            marital 36
        spend 40                spend2 44               spend3 48
        spend4 52               eqopp 56                eqrandom 60
        ideo 64                 party 68                race 71-72
        ;

  LABEL
   CASEID  = 'Case ID (numeric)'
   charid  = 'Character version of CASEID'
   age     = 'Age of respondent in years'
   casewt  = 'Overall sampling weight'
   educ    = 'Education in years of schooling'
   employed= 'Employment status'
   gender  = 'Gender of respondent'
   income  = 'Income of household'
   marital = 'Marital status'
   spend   = 'Military spending'
   spend2  = 'Urban problems spending'
   spend3  = 'Crime reduction spending'
   spend4  = 'Welfare spending'
   eqopp   = 'Eq opp for Blks/Wmen not job of govt'
   eqrandom= 'Random number variable for eqopp'
   ideo    = 'Political ideology in general'
   party   = 'Party identification'
   race    = 'Race or ethnic group'  ;

  FORMAT age age. educ educ. employed employed.
         gender gender. income income. marital marital.
         spend spend. spend2 spend2ff. spend3 spend3ff.
         spend4 spend4ff. eqopp eqopp. eqrandom eqrandom.
         ideo ideo. party party. race race.
          ;


IF (age = 99) THEN age = .;
IF (educ = 99) THEN educ = .;
IF (employed = 99) THEN employed = .;
IF (income = 88 OR income = 99) THEN income = .;
IF (marital = 8 OR marital = 9) THEN marital = .;
IF (spend = 8 OR spend = 9) THEN spend = .;
IF (spend2 = 8 OR spend2 = 9) THEN spend2 = .;
IF (spend3 = 8 OR spend3 = 9) THEN spend3 = .;
IF (spend4 = 8 OR spend4 = 9) THEN spend4 = .;
IF (eqopp = 8 OR eqopp = 9) THEN eqopp = .;
IF (ideo = 8 OR ideo = 9) THEN ideo = .;
IF (party = 8 OR party = 9) THEN party = .;
IF (race = 88 OR race = 99) THEN race = .;

PROC DATASETS;
  CONTENTS DATA=IN POSITION;
  TITLE 'CONTENTS OF ALL VARIABLES';
RUN;




2. SPSS data definitions


 /*  SPSS Data Definition File

TITLE "SDA Test Data".

DATA LIST fixed records=1
  FILE="x"  /* Replace 'x' with full path name of your input data file.
 /1          CASEID 5-10         charid 5-10 (A)                 age 3-4
        casewt 11-16 (3)              educ 19-20          employed 23-24
               gender 28            income 31-32              marital 36
                spend 40               spend2 44               spend3 48
               spend4 52                eqopp 56             eqrandom 60
                 ideo 64                party 68              race 71-72

   .

VARIABLE LABELS
   CASEID    'Case ID (numeric)' /
   charid    'Character version of CASEID' /
   age       'Age of respondent in years' /
   casewt    'Overall sampling weight' /
   educ      'Education in years of schooling' /
   employed  'Employment status' /
   gender    'Gender of respondent' /
   income    'Income of household' /
   marital   'Marital status' /
   spend     'Military spending' /
   spend2    'Urban problems spending' /
   spend3    'Crime reduction spending' /
   spend4    'Welfare spending' /
   eqopp     'Eq opp for Blks/Wmen not job of govt' /
   eqrandom  'Random number variable for eqopp' /
   ideo      'Political ideology in general' /
   party     'Party identification' /
   race      'Race or ethnic group' /
   .

VALUE LABELS
   age       97 '97+ yrs' 99 'Refused' /
   educ      8 'thru 8th' 12 'HS  grad' 16 'Col grad' 99 'Refused' /
   employed  10 'Fulltime' 15 'Parttime' 20 'Laid off' 40 'Unemployed'
             50 'Retired' 60 'Perm disabled' 65 'Temp disabled'
             70 'Keep house' 80 'Student' 90 'Other' 99 'Refused' /
   gender    1 'Male' 2 'Female' /
   income    1 '< 15' 2 '15' 3 '15- 25' 4 '25' 5 '25- 35' 6 '35' 7 '35- 40'
             8 '40' 9 '40- 50' 10 '50' 11 '50+' 81 '25- 40' 82 '>25' 83 '>40'
             84 '<25' 88 'DK' 91 '25- 40' 92 '>25' 93 '>40' 94 '<25'
             99 'Refused' /
   marital   1 'Married' 2 'Like married' 3 'Widowed' 4 'Separated'
             5 'Divorced' 6 'Never married' 8 'Don''t know' 9 'Refused' /
   spend     1 'Too much' 3 'About right' 5 'Too little' 8 'Don''t know'
             9 'Refused' /
   spend2    1 'Too much' 3 'About right' 5 'Too little' 8 'Don''t know'
             9 'Refused' /
   spend3    1 'Too much' 3 'About right' 5 'Too little' 8 'Don''t know'
             9 'Refused' /
   spend4    1 'Too much' 3 'About right' 5 'Too little' 8 'Don''t know'
             9 'Refused' /
   eqopp     1 'Agree' 5 'Disagree' 8 'Don''t know' 9 'Refused' /
   eqrandom  1 'Blacks' 2 'Women' /
   ideo      1 'Liberal' 3 'Conservative' 5 'Moderate' 7 'Don''t label'
             8 'DK' 9 'Refused' /
   party     1 'Republican' 3 'Democrat' 5 'Independent' 6 'No preference'
             7 'Other' 8 'Don''t know' 9 'Refused' /
   race      1 'White' 2 'Black' 3 'Hispanic' 4 'Native American' 5 'Asian'
             6 'Filipino' 7 'Vol: Jewish' 8 'Other' 99 'Refused' /
   .


MISSING VALUES  age (99).
MISSING VALUES  educ (99).
MISSING VALUES  employed (99).
MISSING VALUES  income (88,99).
MISSING VALUES  marital (8,9).
MISSING VALUES  spend (8,9).
MISSING VALUES  spend2 (8,9).
MISSING VALUES  spend3 (8,9).
MISSING VALUES  spend4 (8,9).
MISSING VALUES  eqopp (8,9).
MISSING VALUES  ideo (8,9).
MISSING VALUES  party (8,9).
MISSING VALUES  race (88,99).





3. Stata data definitions


 /*  Stata Data Definition File

*******************************************************************
*  Stata "do-file" file with labels and missing data specifications
*
*  Note that the data dictionary is given at the end of this file.
*  It is used as a separate file, but it is combined with the
*  "do-file" for conversion to DDI or DDL.
*******************************************************************


label data "SDA Test Data"

#delimit ;
label define age       97 "97+ yrs" 99 "Refused" ;
label define educ      8 "thru 8th" 12 "HS  grad" 16 "Col grad" 99 "Refused" ;
label define employed  10 "Fulltime" 15 "Parttime" 20 "Laid off"
                       40 "Unemployed" 50 "Retired" 60 "Permanently disabled"
                       65 "Temporarily disables" 70 "Keep house" 80 "Student"
                       90 "Other" 99 "Refused" ;
label define gender    1 "Male" 2 "Female" ;
label define income    1 "< 15" 2 "15" 3 "15- 25" 4 "25" 5 "25- 35" 6 "35"
                       7 "35- 40" 8 "40" 9 "40- 50" 10 "50" 11 "50+"
                       81 "25- 40" 82 ">25" 83 ">40" 84 "<25" 88 "Don't know"
                       91 "25- 40" 92 ">25" 93 ">40" 94 "<25" 99 "Refused" ;
label define marital   1 "Married" 2 "Like married" 3 "Widowed" 4 "Separated"
                       5 "Divorced" 6 "Never married" 8 "Don't know"
                       9 "Refused" ;
label define spend     1 "Too much" 3 "About right" 5 "Too little"
                       8 "Don't know" 9 "Refused" ;
label define spend2    1 "Too much" 3 "About right" 5 "Too little"
                       8 "Don't know" 9 "Refused" ;
label define spend3    1 "Too much" 3 "About right" 5 "Too little"
                       8 "Don't know" 9 "Refused" ;
label define spend4    1 "Too much" 3 "About right" 5 "Too little"
                       8 "Don't know" 9 "Refused" ;
label define eqopp     1 "Agree" 5 "Disagree" 8 "Don't know" 9 "Refused" ;
label define eqrandom  1 "Blacks" 2 "Women" ;
label define ideo      1 "Liberal" 3 "Conservative" 5 "Moderate"
                       7 "Never think of myself in those terms"
                       8 "Don't know" 9 "Refused" ;
label define party     1 "Republican" 3 "Democrat" 5 "Independent"
                       6 "No preference" 7 "Other" 8 "Don't know" 9 "Refused" ;
label define race      1 "White" 2 "Black" 3 "Hispanic" 4 "Native American"
                       5 "Asian" 6 "Filipino" 99 "Refused" ;


#delimit cr

*******************************************************************
infile using X
* Replace 'X' with the name of the dictionary file.
*******************************************************************
* The md, min and max specifications were translated
* into the following "REPLACE...IF" statements:

replace age = . if (age == 99)
replace educ = . if (educ == 99)
replace educ = . if (educ > 17)
replace employed = . if (employed == 99)
replace income = . if (income == 88 | income == 99)
replace income = . if (income > 11)
replace marital = . if (marital == 8 | marital == 9)
replace spend = . if (spend == 8 | spend == 9)
replace spend2 = . if (spend2 == 8 | spend2 == 9)
replace spend3 = . if (spend3 == 8 | spend3 == 9)
replace spend4 = . if (spend4 == 8 | spend4 == 9)
replace eqopp = . if (eqopp == 8 | eqopp == 9)
replace ideo = . if (ideo == 8 | ideo == 9)
replace ideo = . if (ideo > 5)
replace party = . if (party == 8 | party == 9)
replace party = . if (party > 5)
replace race = . if (race == 88 | race == 99)


dictionary using Y {
*****************************************************************
*  This dictionary is used as a separate file, but it is combined
*  with the "do-file" file for conversion to DDI or DDL.
*****************************************************************
*  Records per case:
_lines(1)

_line(1)

_column(5)     long  CASEID             %6f    "Case ID (numeric)"
_column(5)     str6  charid             %6s    "Character version of CASEID"
_column(3)     int   age      :age      %2f    "Age of respondent in years"
_column(11)    float casewt             %6.3f  "Overall sampling weight"
_column(19)    int   educ     :educ     %2f    "Education in years of schooling"
_column(23)    int   employed :employed %2f    "Employment status"
_column(28)    int   gender   :gender   %1f    "Gender of respondent"
_column(31)    int   income   :income   %2f    "Income of household"
_column(36)    int   marital  :marital  %1f    "Marital status"
_column(40)    int   spend    :spend    %1f    "Military spending"
_column(44)    int   spend2   :spend2   %1f    "Urban problems spending"
_column(48)    int   spend3   :spend3   %1f    "Crime reduction spending"
_column(52)    int   spend4   :spend4   %1f    "Welfare spending"
_column(56)    int   eqopp    :eqopp    %1f    "Eq opp for Blks/Wmen not job of govt"
_column(60)    int   eqrandom :eqrandom %1f    "Random number variable for eqopp"
_column(64)    int   ideo     :ideo     %1f    "Political ideology in general"
_column(68)    int   party    :party    %1f    "Party identification"
_column(71)    int   race     :race     %2f    "Race or ethnic group"
}


DDL file produced by those data definitions


path        = .
title       = SDA Test Data
records/case= 1
reclen      = 72
*
name        = CASEID
label       = Case ID (numeric)
type        = numeric
record      = 1
column      = 5
width       = 6
*
name        = charid
label       = Character version of CASEID
type        = character
record      = 1
column      = 5
width       = 6
*
name        = age
label       = Age of respondent in years
type        = numeric
record      = 1
column      = 3
width       = 2
md          = 99
catlabels   = 97 97+ yrs
              99 Refused
*
name        = casewt
label       = Overall sampling weight
type        = numeric
record      = 1
column      = 11
width       = 6
decimals    = 3
*
name        = educ
label       = Education in years of schooling
type        = numeric
record      = 1
column      = 19
width       = 2
md          = 99
catlabels   = 8 thru 8th
              12 HS  grad
              16 Col grad
              99 Refused
*
name        = employed
label       = Employment status
type        = numeric
record      = 1
column      = 23
width       = 2
md          = 99
catlabels   = 10 Fulltime
              15 Parttime
              20 Laid off
              40 Unemployed
              50 Retired
              60 Perm disabled
              65 Temp disabled
              70 Keep house
              80 Student
              90 Other
              99 Refused
*
name        = gender
label       = Gender of respondent
type        = numeric
record      = 1
column      = 28
width       = 1
catlabels   = 1 Male
              2 Female
*
name        = income
label       = Income of household
type        = numeric
record      = 1
column      = 31
width       = 2
md          = 88,99
catlabels   = 1 < 15
              2 15
              3 15- 25
              4 25
              5 25- 35
              6 35
              7 35- 40
              8 40
              9 40- 50
              10 50
              11 50+
              81 25- 40
              82 >25
              83 >40
              84 <25
              88 DK
              91 25- 40
              92 >25
              93 >40
              94 <25
              99 Refused
*
name        = marital
label       = Marital status
type        = numeric
record      = 1
column      = 36
width       = 1
md          = 8,9
catlabels   = 1 Married
              2 Like married
              3 Widowed
              4 Separated
              5 Divorced
              6 Never married
              8 Don't know
              9 Refused
*
name        = spend
label       = Military spending
type        = numeric
record      = 1
column      = 40
width       = 1
md          = 8,9
catlabels   = 1 Too much
              3 About right
              5 Too little
              8 Don't know
              9 Refused
*
name        = spend2
label       = Urban problems spending
type        = numeric
record      = 1
column      = 44
width       = 1
md          = 8,9
catlabels   = 1 Too much
              3 About right
              5 Too little
              8 Don't know
              9 Refused
*
name        = spend3
label       = Crime reduction spending
type        = numeric
record      = 1
column      = 48
width       = 1
md          = 8,9
catlabels   = 1 Too much
              3 About right
              5 Too little
              8 Don't know
              9 Refused
*
name        = spend4
label       = Welfare spending
type        = numeric
record      = 1
column      = 52
width       = 1
md          = 8,9
catlabels   = 1 Too much
              3 About right
              5 Too little
              8 Don't know
              9 Refused
*
name        = eqopp
label       = Eq opp for Blks/Wmen not job of govt
type        = numeric
record      = 1
column      = 56
width       = 1
md          = 8,9
catlabels   = 1 Agree
              5 Disagree
              8 Don't know
              9 Refused
*
name        = eqrandom
label       = Random number variable for eqopp
type        = numeric
record      = 1
column      = 60
width       = 1
catlabels   = 1 Blacks
              2 Women
*
name        = ideo
label       = Political ideology in general
type        = numeric
record      = 1
column      = 64
width       = 1
md          = 8,9
catlabels   = 1 Liberal
              3 Conservative
              5 Moderate
              7 Don't label
              8 DK
              9 Refused
*
name        = party
label       = Party identification
type        = numeric
record      = 1
column      = 68
width       = 1
md          = 8,9
catlabels   = 1 Republican
              3 Democrat
              5 Independent
              6 No preference
              7 Other
              8 Don't know
              9 Refused
*
name        = race
label       = Race or ethnic group
type        = numeric
record      = 1
column      = 71
width       = 2
md          = 88,99
catlabels   = 1 White
              2 Black
              3 Hispanic
              4 Native American
              5 Asian
              6 Filipino
              7 Vol: Jewish
              8 Other
              99 Refused



CSM, UC Berkeley/ISA
March 18, 2019